import { createRouter, createWebHashHistory } from 'vue-router';

// 1. 定义路由规则
const routes = [
    {
        path: '/',
        name: 'main',
        component: () => import('@/views/Main.vue'),
        redirect: '/home',
        children: [
            {
                path: 'home',
                name: 'home',
                component: () => import('@/views/Home.vue')
            },
            {
                path: 'user',
                name: 'user',
                component: () => import('@/views/User.vue')
            },
        ],
    },
]

// 2. 创建路由实例并传递 `routes` 配置
const router = createRouter({
    // 设置路由模式
    history: createWebHashHistory(),
    routes
})

export default router;
